package com.usian.article.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usian.api.article.ApArticleContentControllerApi;
import com.usian.api.article.ApArticleControllerApi;
import com.usian.article.service.ApArticleContentService;
import com.usian.model.article.pojos.ApArticleContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Auther:ASS
 * @Date:2023/2/22 11:18
 */
@RestController
@RequestMapping("/api/v1/articleContent")
public class ApArticleContentController implements ApArticleContentControllerApi {

    @Autowired
    private ApArticleContentService apArticleContentService;



    /*
    * admin远程保存文章的主表
    *
    * */
    @Override
    @RequestMapping("/saveApArticleContent")
    public ApArticleContent saveApArticleContent(@RequestBody ApArticleContent apArticleContent) {
        return apArticleContentService.saveApArticle(apArticleContent);
    }


    /**
     * search 远程调用查询文章内容详情
     * @param articleId
     * @return
     */

    @Override
    @PostMapping("/findByArticleId")
    public ApArticleContent findByArticleId(Long articleId) {
       return apArticleContentService.getOne(Wrappers.<ApArticleContent>lambdaQuery().eq(ApArticleContent::getArticleId,articleId));

    }
}
